import java.util.Hashtable;
import java.lang.Boolean;
import java.lang.Character;
public class function
{
	/*
	 * find the most frequent word(s) in a Word doc. What are the things
you need to clarify before coding?
	 */
	public void findmostfrequentword(char [] str)
	{
		Hashtable<String,Integer>hash=new Hashtable();
		
		int max=0;
		StringBuffer sb=new StringBuffer();
		boolean getchar=false;
		boolean getblank=false;
		for(int i=0;i<str.length;i++)
		{
			if(str[i]==' ')
			{
				getblank=true;
				if(getchar)
				{Integer time=hash.get(sb.toString());
					if(time!=null)
					{
						
						int frequency=time.intValue()+1;
						if(frequency>max)
							max=frequency;
						hash.put(sb.toString(), frequency);
						
					}
					else
					{
						if(max<1)
							max=1;
						hash.put(sb.toString(), new Integer(1));
					}
					getchar=false;
				}
				sb.setLength(0);
			}
			else//get the non blank character
			{
				if(getblank)
				{
					getblank=false;
					getchar=true;
				}
				sb.append(str[i]);
				
				
			}
		}
		if(getchar)
		{
			Integer time=hash.get(sb.toString());
		if(time!=null)
		{
			
			int frequency=time.intValue()+1;
			hash.put(sb.toString(), frequency);
			if(frequency>max)
				max=frequency;
			
		}
		else
		{
			hash.put(sb.toString(), new Integer(1));
			if(max<1)
				max=1;
		}
		}
	
			System.out.println("max frequecy"+ max);
			
		
	}
	public void remove(char[]str1,char[]str2)//remove the character in str2 from str1
	{
		Hashtable<Character,Boolean>hash=new Hashtable<Character,Boolean>();
		int leftlen=str1.length;
		int rightlen=str2.length;
		for(int i=0;i<rightlen;i++)
			hash.put(new Character(str2[i]), new Boolean(true));
		int insertposition=0;
		for(int i=0;i<leftlen;i++)
		{
			if(hash.get(new Character(str1[i]))!=null)
				continue;
			else
				str1[insertposition++]=str1[i];
		}
		for(int i=0;i<insertposition;i++)
			System.out.println(str1[i]);
		
		
	}
	public void test_permutionofstring()
	{
		String test="abcd";
		StringBuffer sb=new StringBuffer();
		char[]str=test.toCharArray();
		int level=0;
		int length=test.length();
		
		boolean []tag=new boolean[length];
		for(int i=0;i<length;i++)
			tag[i]=false;
		permute(str,level,length,sb,tag);
		
		
		
	}
	void permute(char[]str,int level,int length,StringBuffer sb,boolean []tag)
	{
		if(level==length)
			
			{
			System.out.println(sb.toString());
			return;
			}
			
	else
	{
		for(int i=0;i<length;i++)
		{
			if(tag[i])
				continue;
			else
			{
				sb.append(str[i]);
				tag[i]=true;
				permute(str,level+1,length,sb,tag);
				tag[i]=false;
				sb.setLength( sb.length() - 1 );

				
				
			}
			
		}
	}
		
			
			
		
	}
	
	void combine( String str ){
	    int           length = str.length();
	    char[]        instr = str.toCharArray();
	    StringBuilder  outstr = new StringBuilder ();
	    doCombine( instr, outstr, length, 0, 0 );
	}

	void doCombine( char[] instr, StringBuilder  outstr, int length,
	                int level, int start ){
	    for( int i = start; i < length; i++ ){
	        outstr.append( instr[i] );
	        System.out.println( outstr );

	        if( i < length - 1 ){
	            doCombine( instr, outstr, length, level + 1, i + 1 );
	        }

	        outstr.setLength(outstr.length() - 1);
	    }
	}

public static void main(String args[])
{
	String str1="good by yestoday good sex and yestoday and and and and and ";
	
	char[]str2={'o','b'};
	
	function f=new function();
	f.findmostfrequentword(str1.toCharArray());
	//f.test_permutionofstring();
	//f.combine("wxyz");
	f.remove(str1.toCharArray(), str2);
}

}